package com.yks.demo.lvcr.democlient.controller;


import com.yks.demo.lvcr.democlient.entity.DemoUser;
import com.yks.demo.lvcr.democlient.service.IDemoUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/userController")
public class DemoUserController {

    @Autowired
    private IDemoUserService demoUserService;


    @RequestMapping("/addUser/{name}/{age}")
    public String addUser(@PathVariable String name,@PathVariable Integer age){
        DemoUser demoUser = new DemoUser();
        demoUser.setUserName(name);
        demoUser.setAge(age);
        demoUserService.addUser(demoUser);
        return "ok";
    }


    @RequestMapping("/testWaitTimeOut/{name}/{age}")
    public String testWaitTimeOut(@PathVariable String name,@PathVariable Integer age){
        DemoUser demoUser = new DemoUser();
        demoUser.setUserName(name);
        demoUser.setAge(age);
        demoUserService.testWaitTimeOut(demoUser);
        return "ok";
    }

    @RequestMapping("/testMaxIdleTimeOut/{name}/{age}")
    public String testMaxIdleTimeOut(@PathVariable String name,@PathVariable Integer age){
        DemoUser demoUser = new DemoUser();
        demoUser.setUserName(name);
        demoUser.setAge(age);
        demoUserService.testMaxIdleTimeOut(demoUser);
        return "ok";
    }


    @RequestMapping("/testTransaction/{name}/{age}")
    public String testTransaction(@PathVariable String name,@PathVariable Integer age){
        DemoUser demoUser = new DemoUser();
        demoUser.setUserName(name);
        demoUser.setAge(age);
        demoUserService.testTransactionParent(demoUser);
        return "ok";
    }


    @RequestMapping("/testTransaction2/{name}/{age}")
    public String testTransaction2(@PathVariable String name,@PathVariable Integer age){
        DemoUser demoUser = new DemoUser();
        demoUser.setUserName(name);
        demoUser.setAge(age);
        demoUserService.testTransaction(demoUser);
        return "ok";
    }




}
